Namespace - LJCDBClientLib
Parameters
dataObject - The record object.
propertyNames - The included column property names.
Returns
The result object.
Syntax
C# |
public DbResult Add(Object dataObject, List<String> propertyNames = null)
|
Adds a record to the database.
(RE)
Remarks
Parameters
propertyNames
This parameter defines the primary table column values that are to be
added. If it is null, then all the primary table column values are
added.
It must not include Calculated or Join columns or it will cause an error.
Creates an "Insert"
DbRequest
object, which is available in the Request property. The request object is
passed to the
ExecuteRequest()
method.
The Key Columns are assigned from the LookupColumnNames property.
The Key Columns are those columns whose value will be used to find the
added record. This is to return the DB Assigned column values to the
calling program.
The Key Columns must include the DB Assigned columns for the assigned
values to be returned to the calling program. The value must be set to
zero to prevent including it as a key value?
The Lookup Retrieve call will not include keys with a value of "0".
The Add Data Object property names must be the same as the Request Column
property names to map the values into the Key Columns.
Method Graph
All methods are in LJCDBMessage.DbCommon.
RequestDataColumns(dataObject)
RequestColumns(baseDefinition)
DataColumns(dataObject)
CreateValueColumn(dbColumn)
RequestLookupKeys(dataObject)
RequestColumns(baseDefinition)
LookupKeys(dataObject)
IsKeyColumn(dbColumn)
Example
C# |
using LJCNetCommon;
using LJCDBMessage;
public class PersonManager
{
dataObject
propertyNames
public Person Add(Person dataObject, List<string> propertyNames = null)
{
Person retValue = null;
mDataManager.SetDbAssignedColumnNames(new string[]
{
"Id"
});
mDataManager.AddLookupColumnNames(new string[]
{
"Name"
});
DbResult dbResult = mDataManager.Add(dataObject, propertyNames);
AffectedCount = mDataManager.AffectedCount;
SQLStatement = mDataManager.SQLStatement;
if (dbResult != null && dbResult.DbRecords.Count > 0)
{
retValue = new Person();
DbCommon.SetObjectValues(dbResult.DbRecords[0], retValue);
}
int personId = retValue.PersonId;
return retValue;
}
}
|
Copyright © Lester J. Clark and Contributors.
Licensed under the MIT License.